<?php if(!empty($subvo)){
    $v = $subvo;
    $subvo = '';
}
if(!empty($subsubvo)){
    $v = $subsubvo;
    $subsubvo = '';
}
?>




<div class="viewBox myBox<?php echo $v['id'];?>" <?php if($_SESSION[C('USER_AUTH_KEY')]){?> sortID="<?php echo $v['sort'];?>" modulesID="<?php echo $v['id'];?>" title="<?php echo $v['title'];?>" deleteUrl="<?php echo U('/Admin/Modules/delete',array('id'=>$v['id']));?>" settingUrl="<?php echo U('/Admin/Modules/edit',array('id'=>$v['id']));?>" isEdit="0"<?php }?>>
  <?php if(!empty($v['dataname'])){
                $v['content'] = $v['dataname'];
                
        }
         ?>
         <div class="panel panel-primary">
    <?php include(TMPL_PATH.'Home/TemplateDefault/Public-Moduletitle'.C('TMPL_TEMPLATE_SUFFIX')); ?>
<div class="panel-body">

<form class="checkoutform" id="checkout" action="<?php echo U('createOrder');?>" method="post">

<div class="main">
   <!-- 免运费 -->
   
   <?php if($noshipping == 0){?>
      <div class="panel panel-default" style="border-radius:0; margin-bottom:5px; margin-top:5px;">
        <div class="panel-body">
          <a href="javascript:void(0);" onClick="editAddress();">
          <div class="row">
          <div class="col-xs-2"></div>
          <div class="col-xs-8">
            
            <span style="color:red; font-size:14px;" >
            <empty name="address">           
            <span id="getaddress" style="color:#000000; font-size:13px; "><a href="<?php if(!is_weixin()){?><?php echo U('address');?><?php }?>">点击这里填写地址:</a></span>
            <else />
            <span id="getaddress" style="color:#000000; font-size:13px; "><?php echo $yourname;?>&nbsp;&nbsp;<?php echo $tel;?>&nbsp;&nbsp;<?php echo $address;?></span>
            </empty>
            </span>
            
            
            <input style="display:none;" name="yourname" datatype="*" type="text" id="yourname" nullmsg="收货人姓名不能为空" error="收货人姓名不能为空" value="<?php echo $yourname;?>">
            <input style="display:none;" name="address" datatype="*" type="text" id="address" nullmsg="收货地址不能为空" error="收货地址不能为空" value="<?php echo $address;?>">
            <input style="display:none;" name="tel" datatype="*" type="text" id="tel" nullmsg="电话不能为空" error="电话不能为空" value="<?php echo $tel;?>">
            
            
            
            
            
            </div>
            <div class="col-xs-2"></div>
          </div>
        </div></a>      
      
      </div>
      
      <div style="margin:0 5px;"><a href="<?php echo U('showAddress');?>" class="btn btn-success" style="display:block; margin:5px;">填写配送地址</a>
      </div>
      

      <?php if(!empty($addressSign_info)){?>
      <script type="text/javascript">
    
	//获取共享地址
	function editAddress()
	{

		WeixinJSBridge.invoke(
			'editAddress',
			<?php echo $addressSign_info;?>,
			function(res){
				//alert(res.err_msg);
				
				if(res.err_msg == "edit_address:ok"){
				
				var value1 = res.proviceFirstStageName;
				var value2 = res.addressCitySecondStageName;
				var value3 = res.addressCountiesThirdStageName;
				var value4 = res.addressDetailInfo;
				var address = value1+value2+value3+value4
				var tel = res.telNumber;
				var username = res.userName;
				//alert(value1 + value2 + value3 + value4 + ":" + tel+":"+username);
				var getaddress = "收件人："+username+"&nbsp;电话:&nbsp;"+tel+" <br/> "+"&nbsp;&nbsp;&nbsp;&nbsp;收货地址：&nbsp;"+address;
				
				//alert(username == undefined);
				if(username == undefined || tel == undefined || address == NaN){
					username = '';
					tel = '';
					address = '';
					getaddress = '点击获取地址';
				}
				
				$("#getaddress").html(getaddress);
				document.getElementById("yourname").value = username ;
				document.getElementById("address").value= address ;
				document.getElementById("tel").value= tel ;
				}else{
					//alert(res.err_msg);
					//alert('获取微信地址失败，请手动填写地址');
				}
			}
		);
	}
	
	window.onload = function(){
		if (typeof WeixinJSBridge == "undefined"){
		    if( document.addEventListener ){
		        document.addEventListener('WeixinJSBridgeReady', editAddress, false);
		    }else if (document.attachEvent){
		        document.attachEvent('WeixinJSBridgeReady', editAddress); 
		        document.attachEvent('onWeixinJSBridgeReady', editAddress);
		    }
		}else{
			editAddress();
		}
	};
	
</script>
   <?php }?>
      
      
     <?php }?>
     <!-- 免运费结束 -->
    
     <?php if($noshipping == 0 && !empty($ShippingList)){?>
     
     <input type="hidden" name="shipping_id" class="sendListInput" id="shipping_id" value="" nullmsg="请选择配送方式" datatype="*" errormsg="请选择配送方式">
          <!-- Single button -->
<div class="btn-group" style="padding:5px 10px; width:100%; background:#fff;<?php if(count($ShippingList) == 1){?>display:none;<?php }?>">



  <button type="button" style="width:100%;" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    <span id="shippingname">请选择配送方式</span> <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" style="width:100%; min-width:100%;">
  
  
  <?php foreach($ShippingList as $key => $vo){?>
    <li><a href="javascript:void(0);" onClick="setShipping_id(<?php echo $vo['id'];?>,'<?php echo $vo['title'];?>');"><?php echo $vo['title'];?></a></li>
    
  <?php }?>
    
  </ul>
</div>
<!-- <div style="margin:0 auto"><input type="text" value="给卖家留言" /></div> -->
     <?php } ?>
     
     
     
     
     
     
     
     
     
     
     <!-- 发票管理 -->
     
<?php if(!empty($InvoiceList)){?>
     <input type="hidden" name="invoice_id" class="sendListInput" id="invoice_id" value="">
          <!-- Single button -->
<div class="btn-group" style="padding:5px 10px; width:100%; background:#fff;">



  <button type="button" style="width:100%;" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    <span id="invoicename">选择发票类型</span> <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" style="width:100%; min-width:100%;">
  <li><a href="javascript:void(0);" onClick="setInvoice_id(0,'不需要发票');">不需要发票</a></li>

  <?php foreach($InvoiceList as $key => $vo){?>
    <li><a href="javascript:void(0);" onClick="setInvoice_id(<?php echo $vo['id'];?>,'<?php echo $vo['title'];?>');"><?php echo $vo['title'];?></a></li>
    
  <?php }?>
    
  </ul>
  
  
  
  
</div>

<div class="btn-group" id="taxtitle" style="padding:5px 10px; width:100%; display:none; background:#fff;"><input class="form-control" value="" name="taxtitle" type="text" placeholder="请填写抬头" errormsg="您选择开发票，请填写抬头！" nullmsg="您选择开发票，请填写抬头！"></div>

<script>
	 function setInvoice_id(id, title){
		 $('#invoice_id').val(id); 
		 if(id > 0){
			 $('#taxtitle').find('input').attr('datatype', '*');
			 $('#taxtitle').show();
			 $(".checkoutform").Validform({
				 tiptype:1
			 });
		 }else{
			 $('#taxtitle').hide();
			 $('#taxtitle').find('input').removeAttr('datatype');
			 $(".checkoutform").Validform({
				 tiptype:1
			 });
		 }
		 
		 
		 
		 
		 $.post('<?php echo U('echoShippingFee');?>', sendData(), function(data){
			 //$('#Shippingfee').html(data.shipping_fee);
			 $('#invoice_id').val(id); 
			 $('#invoicename').html('发票类型：'+title+' ');
			 $('#_total').html(data.total);
		 },'json'); 
	 }
</script>
<?php }?>

     
     <!-- 发票管理 -->
     
     
     
     
     
     
     
     
     
     
     
     <!-- 积分抵现 -->
     
     <div style="margin:0 5px;"><?php if(is_array($integral_pay) and $integral > 0){?>
         <div class="alert alert-warning" role="alert" style="margin-bottom:5px; padding:5px;">
      <strong>温馨提示:</strong>您有<?php echo $integral;?>积分可用于抵现。当前订单允许使用<?php echo $integral_pay['integralsum'];?>积分。
    </div>
    <input onBlur="integralPay(this);" type="number" id="integral" name="integral_pay" class="form-control sendListInput">
    
    
    <script>
	   function integralPay(e){
		   $.post('<?php echo U('echointegralPay');?>',sendData(), function(data){
			   if(data.status == 1){
				    $('#_total').html('¥'+data.total);
					
				}else{
					error(data.info);
				}  
		   }, 'json');  
	   }
	</script>
    
     <?php }?></div>
     
     <!-- 积分抵现结束 -->
     
     
     
     <div style="margin:0 5px;">
        <input  type="text"  name="Guestbook" class="form-control sendListInput" placeholder="给我留言">
     </div> 
       
     
       
       
       
       
       
       
       <div class="panel panel-info" style=" margin: 5px 5px 0px 5px ;">
        <div class="panel-heading"><i class="glyphicon glyphicon-list"></i> 货品列表</div>
        <?php $mykey = 0; foreach($productList as $key => $vo){?>
        
        <?php if($mykey > 0){?>
        <div class="line_" style="height:1px; margin:0 5px; background:#ddd;"></div>
        <?php }?>
        
        <div class="media" style="position:relative;" id="cart_<?php echo $vo['id'];?>">
      <div class="media-left">
        <a href="##" style="width:80px; height:80px; display:block;">
          <img width="80" height="80" class="media-object" src="<?php echo getThumbPath($vo['img_url']);?>" data-holder-rendered="true" style="width: 80px; height: 80px;">
        </a>
      </div>
      <div class="media-body">
        <h4 class="media-heading" style="font-weight:normal; color:#999;"><?php echo $vo['title'];?></h4>
        <p>
            
            <?php if(!empty($vo['attrmes'][0])){?>
             <span style="color:rgba(203,189,190,1.00)">规格:&nbsp;&nbsp;</span>
             <?php foreach($vo['attrmes'] as $vos){?>
              <span><?php echo $vos ?>&nbsp;&nbsp;</span>
            <?php }?>
            <?php }?></p>
            <div class="row" style="line-height:30px;">
              <div class="col-xs-12"><span style="color:#f00; font-size:1.2em; font-weight:bold; ">¥<?php echo $vo['price'];?></span>&nbsp;&times;&nbsp;<?php echo $vo['num'];?></div>
            </div>
            
            
      </div>
      
      
      
      
      
       <!--<a href="javascript:void(0);" style="position:absolute; bottom:5px; font-size:1.5em; right:10px;" onClick="deletecart('<?php echo $cartdata[$key][0];?>',this);"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>-->
      
    </div>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
       <?php $mykey++; }?> 
      </div>
       
       <!-- 配送费用 --><?php if($ShippingList){?>
           <div style="margin:10px; text-align:right; margin-right:20px;">
     配送费用：<span style="color:#f00; font-size:1.3em; font-weight:bold; font-family:Arial;" id="Shippingfee">0</span>
     </div>
     <script>
	 function setShipping_id(id, title){
		 $('#shipping_id').val(id);
		 $.post('<?php echo U('echoShippingFee');?>', sendData(), function(data){
			 $('#Shippingfee').html(data.shipping_fee);
			 
			 $('#shippingname').html('配送方式：'+title+' ');
			 $('#_total').html(data.total);
		 },'json'); 
	 }
	 </script>
     <?php }?>
       <!-- 配送费用结束 -->
       
       
       
       <!-- 发票费用 -->
       
       <!-- 发票费用结束 -->
       
       
       
       
       
       
       <div style="height:80px;"></div>
       <div style="bottom:0px; width:100%; background:rgba(219,214,214,1.00); z-index:10000; height:50px; line-height:50px;">
        
        
        <div class="row">
        <div class="col-sm-7 col-xs-7" style="text-align:left; padding:0; padding-left:8px; line-height:50px;">合计：<span style="font-family:Arial;color:red; font-size:1.5em; font-weight:bold;"><span id="_total">¥<?php echo $total;?></span></span></div>
          
          <div class="col-xs-5" style="padding:0;"><button id="gotopay" disabled type="submit" class="btn btn-danger" style="display:block; height:49px; border-radius:0; width:100%; text-align:center; font-size:1.3em;" ><i class="glyphicon glyphicon-credit-card"></i> 立即支付</button></div>
        </div>
        
        
          
        </div>
       
       
       
      


</div>

</form>


<?php if(strtolower(GROUP_NAME) != 'admin'){?>


<script type="text/javascript">
$(function(){
	//$(".registerform").Validform();  //就这一行代码！;
	$('#gotopay').removeAttr("disabled");
	$(".checkoutform").Validform({
		tiptype:1
	});
})

function sendData(){
	var sendListInput = new Array();
    $('.sendListInput').each(function(index, element) {
	   sendListInput.push('"' +$(this).attr('id') + '":"' + $(this).val() + '"');
    });
	return eval('({' + sendListInput.toString() + '})'); 
}
//如果只有一个配送方式，自动选择
	<?php if(!empty($ShippingList) && count($ShippingList) == 1){?>
	    
		    setShipping_id(<?php echo $ShippingList[0]['id'];?>,'<?php echo $ShippingList[0]['title'];?>');
		

	<?php }?>
</script>

<?php }?>


</div>
</div></div>


